/**
 * 
 */
package masterlink.futures.dao;

import java.util.List;

import masterlink.futures.vo.AlertSend;
import masterlink.futures.vo.EmpGroup;

import org.springframework.stereotype.Repository;

import baytony.util.Util;

/**
 * @author tonyyang
 *
 */
@Repository
public class AlertSendDao extends TimesTenHibernateDao<AlertSend,AlertSend.ID> {
	
	private static final String FIND_ALL="from AlertSend order by updateDt";
	private static final String FIND_BY_BROKER="from AlertSend where id.empno=? and broker=? and account is null order by id.alertId desc";
	private static final String FIND_BY_ACC="from AlertSend where id.empno=? and broker=? and account not null  order by id.alertId desc";
	
	@SuppressWarnings("unchecked")
	@Override
	public List<AlertSend> findAll() {
		return (List<AlertSend>) findByHql(FIND_ALL);
	}
	
	@SuppressWarnings("unchecked")
	public List<AlertSend> findByBroker(EmpGroup e){
		if(e!=null){
			return (List<AlertSend>) findByHql(FIND_BY_BROKER, e.getId().getEmpno(),e.getId().getGroup().getName());
		}
		return null;
	}
	
	@SuppressWarnings("unchecked")
	public List<AlertSend> findByAcc(EmpGroup e){
		if(e!=null){
			return (List<AlertSend>) findByHql(FIND_BY_ACC, e.getId().getEmpno(),e.getId().getGroup().getName());
		}
		return null;
	}
	
}
